# -*- coding: utf-8 -*-

from naoqi import qi
import time

class Audio():
    def __init__(self,mem,speech):
        self.speech=speech
        self.mem=mem
        self.speech.setLanguage("Chinese")
        # self.speech.setVocabulary(["start", "start robot", "start nao", "start nao robot", "continue", "continue nao"], False)
        self.speech.setVocabulary(["启动","走"], False)
        self.speech.subscribe("SpeechRecognition")
    def __del__(self):
        self.speech.unsubscribe("SpeechRecognition")
    def wait_command(self):
        try:
            word = self.mem.getData("WordRecognized")
            print word
            if word[0] == "启动":
                self.speech.unsubscribe("SpeechRecognition")
                return True
            else:
                return False
        except Exception as e :
            print e
            self.speech.unsubscribe("SpeechRecognition")
            return False